//
//  RadioCollectionViewCell.m
//  News_radio
//
//  Created by lanou on 15/12/16.
//  Copyright © 2015年 lanou3G. All rights reserved.
//

#import "RadioCollectionViewCell.h"
#import "RadioListModel.h"

@implementation RadioCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
//        self.layer.borderWidth = 1;
//        self.layer.borderColor = [[UIColor grayColor] CGColor];
        
        CGFloat width = self.bounds.size.width;
        CGFloat height = self.bounds.size.height;
        
        self.radioImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, width, height / 3.0 * 2)];
        self.radioImage.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:self.radioImage];
        
        
        self.radioTitle = [[UILabel alloc] initWithFrame:CGRectMake(5, height - (height / 3.0) + 3, width - 5 * 2, 20)];
        self.radioTitle.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.radioTitle];
        
        
        self.radioDescribe = [[UILabel alloc] initWithFrame:CGRectMake(5, height - (height / 3.0) + 20, width - 5 * 2, 40)];
        self.radioDescribe.font = [UIFont systemFontOfSize:11];
        self.radioDescribe.textColor = [UIColor grayColor];
        self.radioDescribe.numberOfLines = 0;
        [self.contentView addSubview:self.radioDescribe];
        
        
        self.view = [[UIView alloc] initWithFrame:CGRectMake(width / 5.0 * 2, 0, width / 5.0 * 3, 20)];
        self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
        [self.contentView addSubview:self.view];
        
        self.iconPlayCount = [[UIImageView alloc] initWithFrame:CGRectMake(2, 2, 15, 15)];
        self.iconPlayCount.image = [UIImage imageNamed:@"c9cb8b3032"];
        [self.view addSubview:self.iconPlayCount];

        self.playCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.view.bounds.size.width / 3.6, 2, self.view.bounds.size.width - 20, 15)];
        self.playCountLabel.textColor = [UIColor whiteColor];
        self.playCountLabel.font = [UIFont systemFontOfSize:11];
        [self.view addSubview:self.playCountLabel];
        
        
    }
    return self;
}

- (void)setRadioListModel:(RadioListModel *)radioListModel {
    
    if (_radioListModel != radioListModel) {
        _radioListModel = radioListModel;
        

        [self.radioImage setImageWithURL:[NSURL URLWithString:_radioListModel.radio[@"imgsrc"]] placeholderImage:nil];
        self.radioTitle.text = _radioListModel.tname;
        self.radioDescribe.text = _radioListModel.radio[@"title"];
        
        NSString *string = [NSString stringWithFormat:@"%ld",_radioListModel.playCount];
        NSString *string1 = [string substringToIndex:3];
        NSString *resultStr = [[[string1 stringByAppendingString:@"."] stringByAppendingString:[string substringWithRange:NSMakeRange(3, 1)]] stringByAppendingString:@"万"];
        self.playCountLabel.text = resultStr;

    }
    
}

@end
